﻿Public Class frmAlertWindow

  Private Sub frmAlertWindow_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'Declare and Initialize Procedure-Level Variables and Constants
    Dim ptFormLocation As New Point
    Dim intHeight As Integer = Me.Size.Height + ((arlDetectedDrives.Count - 1) * 16)

    'Set the form horizontal position point
    ptFormLocation.X = My.Computer.Screen.Bounds.Size.Width - (Me.Size.Width + 35)

    'Set the form vertical position point
    ptFormLocation.Y = My.Computer.Screen.Bounds.Size.Height - (intHeight + 60)

    'Set the form position
    Me.Location = ptFormLocation

    'Set the form height
    Me.Height = intHeight

    'Loop through the Detected Drives arraylist, creating the labels for each one on the form
    For i As Integer = 0 To arlDetectedDrives.Count - 1
      'Retrieve the current computer information from the Detected Drive arraylist
      Dim strComputerInfo() As String = arlDetectedDrives.Item(i)

      'Create three new labels to hold the computer information
      Dim lblComputerName As New Label()
      Dim lblComputerDrive As New Label()
      Dim lblComputerSpaceLimit As New Label()

      'Set the parameters for the label that is to hold the name of the computer
      With lblComputerName
        .Name = "lbl" & strComputerInfo(0) & "_" & i
        .Text = strComputerInfo(0)
        .Location = New System.Drawing.Point(55, (92 + (20 * i)))
        .Size() = New System.Drawing.Size(100, 16)
      End With

      'Set the parameters for the label that is to hold the drive letter of the computer
      With lblComputerDrive
        .Name = "lbl" & strComputerInfo(0) & "_Drive_" & strComputerInfo(1) & "_" & i
        .Text = strComputerInfo(1)
        .Location = New System.Drawing.Point(165, (92 + (20 * i)))
        .Size() = New System.Drawing.Size(40, 16)
        .TextAlign = ContentAlignment.TopCenter
      End With

      'Set the parameters for the label that is to hold the current free disk space of the computer
      With lblComputerSpaceLimit
        .Name = "lbl" & strComputerInfo(0) & "_Drive_" & strComputerInfo(1) & "_FreeSpace_" & i
        .Text = strComputerInfo(3)
        .Location = New System.Drawing.Point(225, (92 + (20 * i)))
        .Size() = New System.Drawing.Size(110, 16)
        .TextAlign = ContentAlignment.TopCenter
      End With

      'Add the labels to the form
      With Me.Controls
        .Add(lblComputerName)
        .Add(lblComputerDrive)
        .Add(lblComputerSpaceLimit)
      End With
    Next

    'Make the form fade into view
    For o As Integer = 5 To 100 Step 5
      Me.Opacity = o / 100
      Me.Refresh()
      Threading.Thread.Sleep(75)
    Next

    'Set the timer interval and enable the timer
    Me.tmrAlertWindow.Interval = 6500
    Me.tmrAlertWindow.Enabled = True
  End Sub

  Private Sub tmrAlertWindow_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrAlertWindow.Tick
    'Make the form fade out of view
    For o As Integer = 100 To 5 Step -5
      Me.Opacity = o / 100
      Me.Refresh()
      Threading.Thread.Sleep(75)
    Next

    'Close the form
    Me.Close()
  End Sub

  Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
    'Close the form
    Me.Close()
  End Sub

End Class